//package com.zdx.yswl.ui.adapter;
//
//import android.content.Context;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.TextView;
//
//import com.loopj.android.image.SmartImageView;
//import com.zdx.yswl.R;
//import com.zdx.yswl.tool.KNetTool;
//import com.zdx.yswl.ui.bean.HeadImgBean;
//import com.zdx.yswl.ui.bean.HouseType;
//import com.zdx.yswl.ui.bean.NewsBean;
//import com.zdx.yswl.view.listview.BaseListViewAdapter;
//
//public class MainHousetypeAdapter extends BaseListViewAdapter<HeadImgBean> {
//
//	public MainHousetypeAdapter(Context _context) {
//		super(_context);
//	}
//	
//	@Override
//	public View getView(int position, View convertView, ViewGroup parent) {
//		ViewHolder __viewHolder = null;
//		if (convertView == null) {
//			convertView = LayoutInflater.from(this.context).inflate(R.layout.housetype_list_item, null);
//			__viewHolder = new ViewHolder();
//			__viewHolder.image = (SmartImageView) convertView.findViewById(R.id.housetype_image);
//			__viewHolder.introduceTv = (TextView) convertView.findViewById(R.id.housetype_introduce_tv);
//			convertView.setTag(__viewHolder);
//		} else {
//			__viewHolder = (ViewHolder) convertView.getTag();
//		}
//
//		HeadImgBean bean = this.getItem(position);
//		if (KNetTool.isNetworkAvalible(context)) {
//			__viewHolder.image.setImageUrl(bean.url);
//		}else{
//			__viewHolder.image.setImageResource(R.drawable.aio_image_default_round);
//		}
//		__viewHolder.introduceTv.setText(bean.label);
//		return convertView;
//	}
//
//	private static class ViewHolder {
//		public SmartImageView image;
//		public TextView introduceTv;
//	}
//	
//	
//
//}

package com.zdx.yswl.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.loopj.android.image.SmartImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.zdx.yswl.R;
import com.zdx.yswl.ui.bean.HeadImgBean;
import com.zdx.yswl.ui.listener.AnimateFirstDisplayListener;
import com.zdx.yswl.view.listview.BaseListViewAdapter;

public class MainHousetypeAdapter extends BaseListViewAdapter<HeadImgBean> {

	private ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener();
	protected ImageLoader imageLoader = ImageLoader.getInstance();
	
	public MainHousetypeAdapter(Context _context) {
		super(_context);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder __viewHolder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(this.context).inflate(R.layout.housetype_list_item, null);
			__viewHolder = new ViewHolder();
			__viewHolder.image = (SmartImageView) convertView.findViewById(R.id.housetype_image);
			__viewHolder.introduceTv = (TextView) convertView.findViewById(R.id.housetype_introduce_tv);
			convertView.setTag(__viewHolder);
		} else {
			__viewHolder = (ViewHolder) convertView.getTag();
		}

		HeadImgBean bean = this.getItem(position);
		/**smartImageView 加载  */
//		if (KNetTool.isNetworkAvalible(context)) {
//			__viewHolder.image.setImageUrl(bean.url,R.drawable.aio_image_fail_round,R.drawable.aio_image_default_round);
//		}
		/**volly 加载 */
//		HttpUtilsByVolley.loadImage4Url(context, bean.url, __viewHolder.image, R.drawable.aio_image_default_round, R.drawable.aio_image_fail_round);
		/**imageloader 加载 */
		imageLoader.displayImage(bean.url, __viewHolder.image, options, animateFirstListener);
		
		__viewHolder.introduceTv.setText(bean.label);
		return convertView;
	}

	private static class ViewHolder {
		public SmartImageView image;
		public TextView introduceTv;
	}
	
	

}

